package org.apache.solr.ocean.core;

import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.ocean.OceanCore;
import org.apache.solr.ocean.OceanSearcher;
import org.apache.solr.ocean.replication.NodeInfo;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;

public class NodeRequestHandler extends RequestHandlerBase {
  public void handleRequestBody(SolrQueryRequest request, SolrQueryResponse response) throws Exception {
    OceanSearcher searcher = (OceanSearcher)request.getSearcher();
    OceanCore oceanCore = searcher.getCore();
    NodeInfo nodeInfo = oceanCore.getCategory().getTransactionSystem().getReplication().getNodeInfo();
    
    SimpleOrderedMap<Object> nodeInfoMap = new SimpleOrderedMap<Object>();
    nodeInfoMap.add("docId", docId);
    nodeInfoMap.add("lucene", info);
    nodeInfoMap.add("solr", doc);
    
    response.add("nodeinfo", nodeInfoMap);
  }
}
